module mWeakLensing

        use mPrecision

        implicit none

        private
        public :: W

contains

        !*****************************************************************
        ! This is the weak lensing weight function (see Takada, Jain 2002)
        !*****************************************************************
        real(D) function W(chi, a, a_s)
                use mConstants
                use mObject
                use mChi
                type(tChi), intent(in) :: chi
                real(D), intent(in) :: a, a_s
                real(D) :: chiVal, chi_s
                chiVal = a_chi(chi, a)
                chi_s = a_chi(chi, a_s)
                W = 1e5_D * h(chi) / c ! H_0 in Mpc
                W = 1.5_D * omega_m0(chi) * W * W &
                        * chiVal * (chi_s - chiVal) / (a * chi_s)
        end function W

end module mWeakLensing
